<?php
/**
 * Created by PhpStorm.
 * User: shkj
 * Date: 2020/4/22
 * Time: 23:34
 */

namespace app\api\controller\v1;

use think\Db;
use think\facade\Request;
class Type extends Base
{
    private $obj;
    public function __construct() {
        $this->obj = model("Type");
    }
//    public function detail(){
//        $typeId = Request::param('type_id');
//        if($typeId){
//            $map['type_id']=['=',$typeId];
//        }else{
//            $map=1;
//        }
//        $attrRes = Db::name('attr')->alias('a')->field('a.*,t.type_name')->join('type t',"a.type_id = t.id")->where($map)->order('a.id DESC')->select();
//
//        return_json(200,'cs',$attrRes);
//    }
    public function select(){
        $this->obj->select();
    }

    public function add(){
        $data = Request::post();
        $this->obj->add($data);
    }

    public function detail(){
        $id = Request::param('id');
        $this->obj->detail($id);
    }

    public function delete(){
        $id = Request::param('id');
        $this->obj->del($id);
    }

    public function edit(){
        $data = Request::post();
        $this->obj->modify($data);
    }

}